package com.easyfun.healthmagicbox.comm;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONException;
import org.json.JSONObject;

import android.content.Context;

import com.easyfun.healthmagicbox.ormlite.ServerResponseCode;
import com.easyfun.healthmagicbox.pojo.ConstantData;
import com.easyfun.healthmagicbox.sync.CommCallback;

public class HealthInputDataDeleteTask extends BaseRedoTask implements
Runnable{
	String syncid;
	public HealthInputDataDeleteTask(String syncid, Context context, CommCallback callback) {
		super(context, callback);
		this.syncid = syncid;
	}
	public HealthInputDataDeleteTask(Context context,CommCallback callback)
	{
		super(context,callback);
	}
	@Override
	public void run() {
		JSONObject serializedObj = new JSONObject();
		try {
			serializedObj.put("syncid", syncid);
			Map<String, String> parmas = new HashMap<String, String>();
			parmas.put("jsonstring", serializedObj.toString());
			
			String result = super.uploadByHTTP(parmas,
					ConstantData.InputDataDeleteURI);
			
			if (ServerResponseCode.parseOf(result)==ServerResponseCode.SUCCESS) {
				ccb.setCommResult(this,
						"", ServerResponseCode.SUCCESS);
			}else
			{
				ccb.setCommResult(this,
						"", ServerResponseCode.FAILED);
			}
		} catch (JSONException e) {
			ccb.setCommResult(this,
					"", ServerResponseCode.FAILED);
			e.printStackTrace();
		} catch (ClientProtocolException e) {
			ccb.setCommResult(this,
					"", ServerResponseCode.FAILED);
			e.printStackTrace();
		} catch (IOException e) {
			ccb.setCommResult(this,
					"", ServerResponseCode.FAILED);
			e.printStackTrace();
		}
			

		
		
	}

	@Override
	public String serializeParam() {
		return syncid;
	}

	@Override
	public void deserializeParam(String serialstring) {
		syncid = serialstring;
		
	}

}
